function! plugin#vim_slime#load() abort
    if !exists('g:loaded_slime')
        packadd vim-slime
    endif
    return exists('g:loaded_slime')
endfunction

function! plugin#vim_slime#init() abort
    if plugin#vim_slime#load()
        let g:slime_target = "vimterminal"
        let g:slime_vimterminal_cmd = "ipython"
        autocmd FileType python let b:slime_vimterminal_cmd='ipython'
        let g:slime_keymap = get(g:, 'slime_keymap', { 'name': '+slime', 
                    \ 'c': ['<Plug>SlimeConfig'         , 'config'      ],
                    \ 'p': ['<Plug>SlimeParagraphSend'  , 'paragraph'   ], 
                    \ 'r': ['<Plug>SlimeRegionSend'     , 'region'      ], 
                    \ 'l': [':SlimeSendCurrentLine'     , 'line'        ], 
                    \ })
        let g:leader_keymap = get(g:, 'leader_keymap', { 'name': '+leader' })
        let g:leader_keymap.s = g:slime_keymap
        " xmap <leader>s <Plug>SlimeRegionSend
        " nmap <leader>s <Plug>SlimeParagraphSend
        " nmap <c-c>v <Plug>SlimeConfig
        " nmap <c-c><c-c> <Plug>SlimeParagraphSend
        " xmap <c-c><c-c> <Plug>SlimeRegionSend
    endif
endfunction

